<template>
  <cloudPage :isLoading="isLoading">
    <cloudHeader slot="gHeader" background="#121212">
      <view class="grace-header-body">
        <!-- 返回按钮 -->
        <view
          class="grace-header-icons grace-icons icon-arrow-left"
          style="color: #fff"
          @tap.stop="handleNavBack"
        ></view>
        <!-- 中间内容 -->
        <view
          class="grace-header-content-noflex grace-text-center font-32"
          style="color: #fff; font-size: 36rpx"
          >{{ $t("mf.my.detail") }}</view
        >
        <!-- 右侧按钮 -->
        <view class="icons" style="font-size: 38rpx"> </view>
      </view>
    </cloudHeader>
    <view class="container">
      <order-detail-box :data="detail" />
      <view class="order_info">
        <view class="order_info_title">{{ $t("mf.order.order_info") }}</view>
        <view class="flex">
          <view class="flex1">
            <view class="info_text">{{ $t("mf.order.buy_date") }}</view>
            <view class="info_text">{{ $t("mf.order.mining_day") }}</view>
            <view class="info_text">{{ $t("mf.order.order_sn") }}</view>
            <view class="info_text">{{ $t("mf.order.transfer_date") }}</view>
            <view class="info_text">{{ $t("mf.order.transfer_total") }}</view>
            <view class="info_text">{{ $t("mf.order.transfer_power") }}</view>
          </view>
          <view class="">
            <view class="info_data">{{
              detail && detail.created_at | moment("YYYY.MM.DD HH:mm")
            }}</view>
            <view class="info_data">{{ detail && detail.shifang_day }}</view>
            <view class="info_data">{{ detail && detail.order_sn }}</view>
            <view class="info_data">{{
              detail && detail.send_sell_time | moment("YYYY.MM.DD HH:mm")
            }}</view>
            <view class="info_data"
              >{{ detail && detail.sell_price }} USDT</view
            >
            <view class="info_data">{{ detail && detail.power_total }} T</view>
          </view>
        </view>
      </view>
      <view class="transfer_box">
        <button class="transfer_btn" @tap.stop="cancelTransfer">
          {{ $t("mf.order.cancel_transfer") }}
        </button>
      </view>
    </view>
    <cloudPayPassword
      :show="showpay"
      @keyboardDone="payPasswordDone"
      @close="cancelTransfer"
    >
    </cloudPayPassword>
  </cloudPage>
</template>

<script>
import { mapActions } from "vuex";
import orderDetailBox from "../components/orderDetailBox";
export default {
  components: {
    orderDetailBox,
  },
  data() {
    return {
      detail: null,
      isLoading: false,
      showpay: false,
    };
  },
  async onLoad(option) {
    console.log(option.id);
    this.isLoading = true;
    this.detail = await this.orderDetail({
      id: option.id,
      type: "user",
    });
    this.isLoading = false;
  },
  methods: {
    ...mapActions("mf/my", ["orderDetail", "sellOrder", "loadOrderList"]),
    cancelTransfer() {
      this.showpay = !this.showpay;
    },
    async payPasswordDone(data) {
      this.cancelTransfer();
      await this.sellOrder({
        type: "cancel",
        order_id: this.detail.id,
        sell_price: 0,
        pay_password: data.password,
      });
      this.makeToast({ title: "撤销成功" });
      this.price = null;
      this.loadOrderList({ type: "is_sell_in" });
      setTimeout(() => {
        this.handleNavBack();
      }, 1500);
    },
  },
};
</script>

<style scoped>
.container {
  width: 100%;
  box-sizing: border-box;
  padding: 40rpx 20rpx 200rpx;
}
.order_info {
  width: 100%;
  min-height: 356rpx;
  background: linear-gradient(270deg, #1b1b2b 0%, #232534 100%);
  box-shadow: 0px 3px 4px 0px rgba(0, 0, 0, 0.5);
  border-radius: 12rpx;
  box-sizing: border-box;
  padding: 0 30rpx;
}
.order_info_title {
  width: 100%;
  height: 107rpx;
  box-sizing: border-box;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 32rpx;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  line-height: 107rpx;
  margin-bottom: 30rpx;
}
.info_text {
  height: 40rpx;
  font-size: 28rpx;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  line-height: 40rpx;
  margin-bottom: 30rpx;
}
.info_data {
  height: 40rpx;
  font-size: 28rpx;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  line-height: 40rpx;
  margin-bottom: 30rpx;
  text-align: right;
}
.transfer_box {
  position: fixed;
  bottom: 10rpx;
  width: 710rpx;
  height: 110rpx;
  border-radius: 20rpx;
  left: 20rpx;
}
.transfer_btn {
  width: 516rpx;
  height: 72rpx;
  height: 100rpx;
  background-image: url("/static/auth/login/btn_bg.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 55rpx;
  line-height: 100rpx;
  position: absolute;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 34rpx;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #2b2c3e;
}
</style>